package com.xja.zf.service.impl;

import com.xja.zf.entity.House;
import com.xja.zf.entity.Htype;
import com.xja.zf.entity.Street;
import com.xja.zf.mapper.HouseMapper;
import com.xja.zf.mapper.HtypeMapper;
import com.xja.zf.mapper.StreetMapper;
import com.xja.zf.service.ManageService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
@Service(interfaceClass=ManageService.class)
public class ManageServiceImpl implements ManageService {
    @Autowired
    private HtypeMapper htypeMapper;
    @Autowired
    private StreetMapper streetMapper;
    @Autowired
    private HouseMapper houseMapper;
    @Override
    public List<House> selectHouse(House house) throws Exception {
        return houseMapper.selectSelective(house);
    }

    @Override
    @Transactional(readOnly = true)
    public Map<String, Object> init() throws Exception {
        List<Htype> htypeList=htypeMapper.selectAll();
        List<Street> streetList=streetMapper.selectAll();
        Map<String, Object> map = new HashMap<>();
        map.put("htypeList",htypeList);
        map.put("streetList",streetList);
        return map;
    }

    @Override
    @Transactional(readOnly = true)
    public House selectById(Integer id)throws Exception{
        return houseMapper.selectByPrimaryKey(id);
    }
}
